package com.tfswx.jkgl.designer.api;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.tfswx.jkgl.designer.dto.GlgxQueryParam;
import com.tfswx.jkgl.designer.dto.SjmxQueryResult;
import com.tfswx.jkgl.designer.dto.mxgl.MxdyAddInputDTO;
import com.tfswx.jkgl.designer.dto.mxgl.MxdyDeleteInputDTO;
import com.tfswx.jkgl.designer.dto.mxgl.MxdyQueryInputDTO;
import com.tfswx.jkgl.designer.dto.mxgl.MxdyQueryOutputDTO;
import com.tfswx.jkgl.designer.dto.mxgl.MxdyUpdateInputDTO;
import com.tfswx.jkgl.designer.dto.mxgl.MxstgxAddInputDTO;
import com.tfswx.jkgl.designer.dto.mxgl.MxstgxDeleteInputDTO;
import com.tfswx.jkgl.designer.dto.mxgl.MxstgxQueryInputDTO;
import com.tfswx.jkgl.designer.dto.mxgl.MxstgxQueryOutputDTO;
import com.tfswx.jkgl.designer.dto.mxgl.MxstgxUpdateInputDTO;
import com.tfswx.jkgl.designer.service.MxglService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author ricky
 * @date 2021/12/10
 */
@Api(tags = "模型管理")
@RestController
@RequestMapping("api")
@ApiSupport(order = 10)
public class MxglController {

    @Resource
    private MxglService mxglService;

    @ApiOperation("获取关联关系")
    @PostMapping("/queryGlgx")
    public List<SjmxQueryResult> queryGlgx(@RequestBody @Valid GlgxQueryParam queryParam) {
        return mxglService.queryGlgx(queryParam);
    }

    @ApiOperation("添加模型定义")
    @PostMapping("/addMxdy")
    @ApiOperationSupport(order = 10)
    public String addMxdy(@RequestBody @Validated MxdyAddInputDTO inputDTO) {
        return mxglService.addMxdy(inputDTO);
    }

    @ApiOperation("删除模型定义")
    @PostMapping("/deleteMxdy")
    @ApiOperationSupport(order = 20)
    public Boolean deleteMxdy(@RequestBody @Validated MxdyDeleteInputDTO inputDTO) {
        return mxglService.deleteMxdy(inputDTO);
    }

    @ApiOperation("修改模型定义")
    @PostMapping("/updateMxdy")
    @ApiOperationSupport(order = 30)
    public Boolean updateMxdy(@RequestBody @Validated MxdyUpdateInputDTO inputDTO) {
        return mxglService.updateMxdy(inputDTO);
    }

    @ApiOperation("查询模型定义")
    @PostMapping("/queryMxdy")
    @ApiOperationSupport(order = 40)
    public List<MxdyQueryOutputDTO> queryMxdy(@RequestBody @Validated MxdyQueryInputDTO inputDTO) {
        return mxglService.queryMxdy(inputDTO);
    }

    @ApiOperation("添加模型实体关系")
    @PostMapping("/addMxstgx")
    @ApiOperationSupport(order = 50)
    public String addMxstgx(@RequestBody @Validated MxstgxAddInputDTO inputDTO) {
        return mxglService.addMxstgx(inputDTO);
    }

    @ApiOperation("删除模型实体关系")
    @PostMapping("/deleteMxstgx")
    @ApiOperationSupport(order = 60)
    public Boolean deleteMxstgx(@RequestBody @Validated MxstgxDeleteInputDTO inputDTO) {
        return mxglService.deleteMxstgx(inputDTO);
    }

    @ApiOperation("修改模型实体关系")
    @PostMapping("/updateMxstgx")
    @ApiOperationSupport(order = 70)
    public Boolean updateMxstgx(@RequestBody @Validated MxstgxUpdateInputDTO inputDTO) {
        return mxglService.updateMxstgx(inputDTO);
    }

    @ApiOperation("查询模型实体关系")
    @PostMapping("/queryMxstgx")
    @ApiOperationSupport(order = 80)
    public List<MxstgxQueryOutputDTO> queryMxstgx(@RequestBody @Validated MxstgxQueryInputDTO inputDTO) {
        return mxglService.queryMxstgx(inputDTO);
    }
}
